﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Churchtoolkit.Utils.Authentication;
using Churchtoolkit.Utils.MVP;
using Churchtoolkit.Web.Shell.Views;
using Churchtoolkit.DataAccess.Repositories;
using Churchtoolkit.DataAccess.Entities;
using Churchtoolkit.DataAccess.Common;

namespace Churchtoolkit.Web.Shell.Presenters
{
    public class ChangeProfilePicturePresenter : Presenter<IChangeProfilePictureView>
    {
        private MembersRepository _member;
        private IAuthentication _authentication;
        public ChangeProfilePicturePresenter(MembersRepository member, IAuthentication authentication)
        {
            _member = member;
            _authentication = authentication;
        }
        public Members GetCurrentMember()
        {
            EntityResult<Members> currentmember;
            currentmember = _member.Find(items => items.Email = _authentication.CurrentLogedInMember.Email);
            return currentmember.Single();
        }
        public void ChangeProfilePicture()
        {
            _member.Update(this.View.CurrentMember);
        }
    }
}
